// 同步数据库
export default function() {
  const seq = require('./seq');
  const path = require('path');
  const rd = require('rd');

  rd.eachSync(`${ path.resolve(__dirname, '../modules') }`, function(f, s) {
    if (f.lastIndexOf('Model.js') > -1) {
      require(f).default;
    }
  });
// 测试连接
  seq
    .authenticate()
    .then(() => {
      console.log('auth ok');
    })
    .catch(() => {
      console.log('auth err');
    });

// 执行同步数据库   force: true--每次同步都会重新建表，如果不用重新建表，删除即可
  seq.sync({ force: false, alter: true }).then(() => {
    console.log('sync ok');
    process.exit();
  });

}
